package com.hyacinth.netty.attr;

import io.netty.channel.Channel;
import io.netty.util.Attribute;
import io.netty.util.AttributeKey;

/**
 * Function:
 *
 * @author crossoverJie
 *         Date: 2019/1/9 00:57
 * @since JDK 1.8
 */
public class NettyAttrUtil {

    public static String getAttr(Channel channel, AttributeKey<String> key) {
        Attribute<String> attr = channel.attr(key);
        return attr.get();
    }

    public static void setAttr(Channel channel, AttributeKey<String> key, String value) {
        channel.attr(key).set(value);
    }
}
